package com.ymatou.iapi.godmch.service;

import com.google.common.reflect.TypeToken;
import com.ymatou.iapi.godmch.parameter.AgentTypeVo;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;

import java.util.ArrayList;
import java.util.List;

/**
*代理类型列表Call
*FreeMaker Template自动生成代码
*/
public class listagentTypeCall extends YmatouBaseCall{
	private static String opurl ="api/agentType/list";
	
	public listagentTypeCall() {
		super(EnvSetup.getSystemUrl("godmch_iapi"),opurl,"GET","PARAM");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		//client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	public List<AgentTypeVo> getAgentTypes(){
		List<AgentTypeVo> AgentTypeVoList=null;
		try {
			String agentTypes=getJsonObject().get("result").getAsJsonObject().get("agentTypes").getAsJsonArray().toString();
			AgentTypeVoList=(List<AgentTypeVo>) FormatUtil.GSONToObject(agentTypes, new TypeToken<List<AgentTypeVo>>(){}.getType());
		} catch (Exception e) {
		}
		return AgentTypeVoList;
	}
}